package com.gitee.wsl.common.ui.graphics.color.decoder

import androidx.compose.ui.graphics.Color
import com.gitee.wsl.common.ui.theme.local.NamedColor

/**
 * Decodes a [Color] from the name (case-insensitive) of a [NamedColor] (e.g. `red`, `GREEN`, `bLuE`, `aliceblue`).
 */
object NamedColorDecoder : ColorDecoder {
    override fun decode(raw: String): Color? =
        NamedColor.entries
            .find { it.name.equals(raw, ignoreCase = true) }
            ?.color
}
